package com.mytest;

import cn.hutool.core.date.DateUtil;
import org.junit.Test;

public class Main {

    @Test
    public void weekTest() {
        // 指定日期
        String dateString = "2023-08-14";
        
        // 获取指定日期所在周的起始时间
        String startOfWeek = DateUtil.beginOfWeek(DateUtil.parse(dateString)).toString();
        System.out.println("Start of Week: " + startOfWeek);
        
        // 获取指定日期所在周的结束时间
        String endOfWeek = DateUtil.endOfWeek(DateUtil.parse(dateString)).toString();
        System.out.println("End of Week: " + endOfWeek);
/*
Start of Week: 2023-08-14 00:00:00
End of Week: 2023-08-20 23:59:59
 */
    }

    @Test
    public void monthTest() {
        // 指定日期
        String dateString = "2023-08-14";

        // 获取指定日期所在周的起始时间
        String startOfWeek = DateUtil.beginOfMonth(DateUtil.parse(dateString)).toString();
        System.out.println("Start of Month: " + startOfWeek);

        // 获取指定日期所在周的结束时间
        String endOfWeek = DateUtil.endOfMonth(DateUtil.parse(dateString)).toString();
        System.out.println("End of Month: " + endOfWeek);
/*
Start of Month: 2023-08-01 00:00:00
End of Month: 2023-08-31 23:59:59
 */
    }


}